import { approx, UITransform, v3, Vec3, _decorator, Component } from 'cc';
// import { EventName } from './components/eventManager';
import { HexagonJenga_EventName, HexagonJenga_main } from './HexagonJenga_main';
const { ccclass, property } = _decorator;

@ccclass('HexagonJenga_GridDi')
export class HexagonJenga_GridDi extends Component {
    public hor: number = 0;
    public ver: number = 0;
    /** 是否已经有放上去的对象了 */
    public sibIndex: number = 0;
    onLoad() {
        // super.onLoad();
        // this.node.getChildByName("lb").active = false;
        // this.node.setScale(v3(0.8, 0.8));
    }

    setInfo(hor: number, ver: number) {
        this.hor = hor;
        this.ver = ver;
    }

    showSelected(bool: boolean) {
        // this.node.getChildByName("s").active = bool;
        // this.node.getChildByName("c").active = false
    }

    onClick_gridDi() {
        // eventMgt.emit(EventName.clickGridDi, this.hor, this.ver);

        HexagonJenga_main.Instance.node.emit(HexagonJenga_EventName.clickGridDi, this.hor, this.ver);
    }

    setSort(siblingIndex: number) {
        this.sibIndex = siblingIndex;
    }

    isClickInside(pos: Vec3) {
        let width = this.node.getComponent(UITransform).width;
        let height = this.node.getComponent(UITransform).height;
        let curPos = this.node.position;
        if (Math.abs(pos.x - curPos.x) <= width / 2 && Math.abs(pos.y - curPos.y) <= height / 2) return true;
        return false;
    }
}